package main.java.tmi.customer.service.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import main.java.tmi.common.service.impl.AbstractDao;
import main.java.tmi.customer.service.CustomerVO;

import org.springframework.stereotype.Repository;

/**
 * Customer Data Access Object (cust Table)
 *
 * @author min™
 * @since 2012. 04. 24
 */
@Repository
public class CustomerDAO extends AbstractDao {
	
	/**
	 * Customer search
	 * @return List<CustomerVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public List<CustomerVO> getCustomerView(Map<String,String> param) throws SQLException {
				
		return (List<CustomerVO>) list("CustomerDAO.getCustomerView", param);
	}
	
	/**
	 * Customer search
	 * @return List<CustomerVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public int getCustomerViewCount(Map<String,String> param) throws SQLException {
		return Integer.parseInt((String) getSqlMapClientTemplate().queryForObject("CustomerDAO.getCustomerViewCount", param));
	}
	
	/**
	 * Customer search
	 * @return List<CustomerVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public Map<String,String>  getCustomerDetailView(Map<String,String> param) throws SQLException {
		Map<String,String> returnMap ;
        returnMap = (Map<String,String>) selectByPk("CustomerDAO.getCustomerDetailView", param);
        
        return returnMap;
	}
	
	/**
	 * Customer save
	 * @return void
	 * @throws SQLException 
	 */
	public void addCustomer(Map<String,String> param) throws SQLException {
		insert("CustomerDAO.addCustomer", param);
	}
	
	/**
	 * Customer modify
	 * @return void
	 * @throws SQLException 
	 */
	public void modifyCustomer(Map<String,String> param) throws SQLException {
		insert("CustomerDAO.modifyCustomer", param);
	}
	
	/**
	 * Customer del
	 * @return void
	 * @throws SQLException 
	 */
	public void delCustomer(Map<String,String> param) throws SQLException {
		insert("CustomerDAO.delCustomer", param);
	}	
}
